Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lambda): efs filesystems #8602

Merged
merged 63 commits into from
Jul 6, 2020
Merged

feat(lambda): efs filesystems #8602

merged 63 commits into from
Jul 6, 2020

Conversation

pahud
Copy link
Contributor

@pahud pahud commented Jun 17, 2020

feat(lambda): Add EFS Filesystem support

This PR adds filesystemConfigs construct property for lambda.Function and allows lambda functions to mount Amazon EFS Filesystems with the Amazon EFS Access Points.

Close #8595


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@pahud pahud marked this pull request as draft June 17, 2020 16:19
@pahud pahud marked this pull request as ready for review June 17, 2020 17:00
@pahud
Copy link
Contributor Author

pahud commented Jun 17, 2020

Hi @eladb

I am ready for initial round. Can you give me some feedbacks?

@eladb eladb requested a review from nija-at June 17, 2020 17:30
@eladb eladb self-requested a review June 17, 2020 17:31
Copy link
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this @pahud. Comments below -

packages/@aws-cdk/aws-lambda/lib/filesystem.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/lib/filesystem.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/lib/function.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/lib/function.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/lib/function.ts Outdated Show resolved Hide resolved
@nija-at nija-at changed the title feat(lambda): Add EFS Filesystem support feat(lambda): mount efs filesystems Jun 18, 2020
Co-authored-by: Niranjan Jayakar <nija@amazon.com>
@mergify mergify bot dismissed nija-at’s stale review June 18, 2020 14:32

Pull request has been modified.

@pahud pahud mentioned this pull request Jun 18, 2020
Copy link
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving to 'request changes' until a dependent PR is complete and integrated back here - #8631

@pahud pahud marked this pull request as draft June 23, 2020 15:39
@mergify mergify bot dismissed nija-at’s stale review June 23, 2020 15:39

Pull request has been modified.

@pahud
Copy link
Contributor Author

pahud commented Jun 24, 2020

Still WIP. But I am encountering this error and still trying to get it around.

Lambda function accessing the efs.AccessPoint will require all the mount targets of the filesystem be ready before it can access it. The efs.AccessPoint is now a property provided by user, which comes from efs.FileSystem, which creates the CfnMountTargets under the hood.

I was trying to make lambda.Function addDependency() on the access point resource but it seems not working.

image

Any suggestion? @nija-at

@pahud pahud requested a review from eladb July 2, 2020 16:37
@pahud
Copy link
Contributor Author

pahud commented Jul 2, 2020

@eladb I think I've fixed all addressed issues. Please take a look again.

@eladb
Copy link
Contributor

eladb commented Jul 2, 2020

Lgtm @jogold can you do another round?

Copy link
Contributor

@jogold jogold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and is functional 👍

I would personally have gone for a bind() pattern for the FileSystem class in Lambda where all the logic for an EFS filesystem would have been centralized (dependency, IAM and connections). But this can be changed later if the FileSystem class in Lambda is marked @experimental? @eladb @nija-at what do you think?

@pahud pahud requested a review from eladb July 6, 2020 05:00
eladb
eladb previously requested changes Jul 6, 2020
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment about singular file system

@@ -570,6 +595,26 @@ export class Function extends FunctionBase {
}

this.currentVersionOptions = props.currentVersionOptions;

if (props.filesystems) {
// max 1 filesystem allowed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary future proofing.. If only a single file system is allowed, then why do we need the property to be filesystems? Shall we change it to filesystem? In the future if we want to add additional filesystems, we can either deprecate the singular property or add additionalFileSystems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Let me revise it.

Copy link
Contributor Author

@pahud pahud Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eladb

It's filesystem now.

And, to even scope down the required iam policies according to the doc, I changed managedPolicies to policies and bake the required policy statements like this in the fromEfsAccessPoint

      policies: [
        new iam.PolicyStatement({
          actions: [ 'elasticfilesystem:ClientMount' ],
          resources: [ '*' ],
          conditions: {
            StringEquals: {
              'elasticfilesystem:AccessPointArn': ap.accessPointArn,
            },
          },
        }),
        new iam.PolicyStatement({
          actions: ['elasticfilesystem:ClientWrite'],
          resources: [ Stack.of(ap).formatArn({
            service: 'elasticfilesystem',
            resource: 'file-system',
            resourceName: ap.fileSystem.fileSystemId,
          }) ],
        }),
      ],

Let me know if it looks better now.

@mergify mergify bot dismissed eladb’s stale review July 6, 2020 07:37

Pull request has been modified.

@pahud pahud requested a review from eladb July 6, 2020 07:47
@mergify
Copy link
Contributor

mergify bot commented Jul 6, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@eladb eladb changed the title feat(lambda): mount efs filesystems feat(lambda): efs filesystems Jul 6, 2020
@mergify
Copy link
Contributor

mergify bot commented Jul 6, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 20563a3
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 8529387 into aws:master Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS Lambda with EFS Filesystem support
5 participants